SetGfxDriver 1:Graphics 800,600,8,2 :SetBuffer FrontBuffer() :SeedRnd MilliSecs()
Include "fn2.bb"
st1#=1256:st2#=1256:st3#=2:st4#=2
While Not KeyHit(1) Or MouseHit(2)
ClsColor 0,0,0
Cls
randnum(0)
getnums()
;	fact_faza():erase()
;	Color 255,255,210:Text 5,5,bit+"/"+unbit+" "+fasecnt+":  "+ tycnt+" maxfase1: "+maxfase1+" minfase2: "+minfase2+"  middle=" + ttt0+"/"+ zzz1 + ", Null cnt=" + cnull+"%, max without Null="+wnullmax+", phase=3",False ,False
	


;checke()
;Color 210,255,210:Text 310,2,in,False ,False
zzz1=zzz1+1:hzzz1=hzzz1+1:jzzz1=jzzz1+1
Flip
If zzz1> 64   Then 
 WaitMouse()
;bit=WaitMouse()
If ((bit<>2) And (tycnt>maxfase1)) Then maxfase1=tycnt
If ((bit=2) And (tycnt<minfase2)) Then minfase2=tycnt	
bit=mod4(bit):
randnum(1):fasecnt=fasecnt+1
EndIf

VWait 
Wend 

Function erase()

		
End Function

Function fact_faza()



;If bit <>2 Then	

		For ut1=0 To 7	
			For i = 0 To 9 
			PokeInt in2,i*5,PeekInt (in1,i*5)			
			Next 			
			For unittest=0 To ut1	
				For i = 0 To 8 
				PokeInt in2,i*5,PeekInt (in2,i*5)Xor   PeekInt (in2,i*5+5)			
				Next 
				PokeInt in2,9*5,PeekInt (in2,0)Xor   PeekInt (in2,9*5)
				


			For ut2=0 To 7
				For i = 0 To 9 
				PokeInt in3,i*5,PeekInt (in2,i*5)			
				Next 		
				For unittest2=0 To ut2	
					For i = 1 To 8 
					PokeInt in3,i*5,PeekInt (in3,i*5)Xor  PeekInt (in3,i*5+5)				
					Next 
					PokeInt in3,9*5,PeekInt (in3,0)Xor   PeekInt (in3,9*5)	
					PokeInt in3,0,PeekInt (in3,5)Xor  PeekInt (in3,0)	
			
				
				For ut3=0 To 7
					For i = 0 To 9 
					PokeInt in4,i*5,PeekInt (in3,i*5)			
					Next 
					For unittest3=0 To ut3	
						For i = 2 To 8 
						PokeInt in4,i*5,PeekInt (in4,i*5)Xor  PeekInt (in4,i*5+5)				
						Next 
						PokeInt in4,9*5,PeekInt (in4,0)Xor   PeekInt (in4,9*5)	
						PokeInt in4,0,PeekInt (in4,5)Xor   PeekInt (in4,0)
						PokeInt in4,5,PeekInt (in4,10)Xor  PeekInt (in4,5)	

				For ut4=0 To 7
					For i = 0 To 9 
					PokeInt in5,i*5,PeekInt (in4,i*5)			
					Next 
					For unittest4=0 To ut4	
						For i = 3 To 8 
						PokeInt in5,i*5,PeekInt (in5,i*5)Xor PeekInt (in5,i*5+5)				
						Next 
						PokeInt in5,9*5,PeekInt (in5,0)Xor   PeekInt (in5,9*5)	
						PokeInt in5,0,PeekInt (in5,5)Xor   PeekInt (in5,0)
						PokeInt in5,5,PeekInt (in5,10)Xor  PeekInt (in5,5)	
						PokeInt in5,10,PeekInt (in5,15)Xor  PeekInt (in5,10)										

				For ut5=0 To 7
					For i = 0 To 9 
					PokeInt in6,i*5,PeekInt (in5,i*5)			
					Next 
					For unittest5=0 To ut5	
						For i = 4 To 8 
						PokeInt in6,i*5,PeekInt (in6,i*5)Xor PeekInt (in6,i*5+5)				
						Next 
						PokeInt in6,9*5,PeekInt (in6,0)Xor   PeekInt (in6,9*5)	
						PokeInt in6,0,PeekInt (in6,5)Xor   PeekInt (in6,0)
						PokeInt in6,5,PeekInt (in6,10)Xor  PeekInt (in6,5)	
						PokeInt in6,10,PeekInt (in6,15)Xor  PeekInt (in6,10)		
						PokeInt in6,15,PeekInt (in6,20)Xor  PeekInt (in6,15)		

				For ut6=0 To 7
					For i = 0 To 9 
					PokeInt in7,i*5,PeekInt (in6,i*5)			
					Next 
					For unittest6=0 To ut6	
						For i = 5 To 8 
						PokeInt in7,i*5,PeekInt (in7,i*5)Xor PeekInt (in7,i*5+5)				
						Next 
						PokeInt in7,9*5,PeekInt (in7,0)Xor   PeekInt (in7,9*5)	
						PokeInt in7,0,PeekInt (in7,5)Xor   PeekInt (in7,0)
						PokeInt in7,5,PeekInt (in7,10)Xor  PeekInt (in7,5)	
						PokeInt in7,10,PeekInt (in7,15)Xor  PeekInt (in7,10)		
						PokeInt in7,15,PeekInt (in7,20)Xor  PeekInt (in7,15)	
						PokeInt in7,20,PeekInt (in7,25)Xor  PeekInt (in7,20)																											
							If (PeekInt (in7,25)=unittest6) And(PeekInt (in6,20)=unittest5) And(PeekInt (in5,15)=unittest4) And(PeekInt (in4,0)=unittest) And (PeekInt (in3,5)=unittest2) And (PeekInt (in2,10)=unittest3)Then untest=unittest:zzz(zzz1)=zzz(zzz1)+1:zzz2(zzz1,zzz2(zzz1,100))=unittest:zzz2(zzz1,100)=zzz2(zzz1,100)+1
							If zzz2(zzz1,100)=0 Then zzz2(zzz1,99)=eee
					Next 			
					Next			
					Next 			
					Next			
	
					Next 			
					Next
	
					Next 			
					Next

				Next
				
			Next
		
		Next	
	Next 			
				
;Else


	
;EndIf 	



End Function